package com.learning.netease.distributed.lock.zk.zklock;


import org.I0Itec.zkclient.exception.ZkMarshallingError;
import org.I0Itec.zkclient.serialize.ZkSerializer;

import java.nio.charset.Charset;


/**
 * ClassName: MyZkSerializer
 * Description: ZkClient 序列化器
 * Date: 2019/3/20 14:19 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class MyZkSerializer implements ZkSerializer {

    @Override
    public byte[] serialize(Object data) throws ZkMarshallingError {
        return String.valueOf(data).getBytes(Charset.forName("UTF-8"));
    }

    @Override
    public Object deserialize(byte[] bytes) throws ZkMarshallingError {
        return new String(bytes, Charset.forName("UTF-8"));
    }
}